package com.spzx.product.api.service;

import com.spzx.common.core.constant.SecurityConstants;
import com.spzx.common.core.constant.ServiceNameConstants;
import com.spzx.common.core.domain.R;
import com.spzx.product.api.domain.vo.CategoryVo;
import com.spzx.product.api.factory.RemoteCategoryFallbackFactory;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;

import java.util.List;

/**
 * 远程调用商品微服务的接口
 * fallback属性：用来配置当前远程调用失败时调用的降级方法的类的类型
 */
@FeignClient(contextId = "remoteCategoryService",value = ServiceNameConstants.PRODUCT_SERVICE,fallbackFactory = RemoteCategoryFallbackFactory.class)
public interface RemoteCategoryService {
    @GetMapping(value = "/category/getOneCategory")
    R<List<CategoryVo> > getOneCategory(@RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @Operation(summary ="获取全部分类" )
    @GetMapping(value = "/category/tree")
    R<List<CategoryVo> > tree(@RequestHeader(SecurityConstants.FROM_SOURCE) String source);
}
